package com.singzi.leetcode.jianzhiOffer;

public class T0050 {
}

class Solution0050 {
    public char firstUniqChar(String s) {
        int[]letter = new int[26];
        for (int i = 0; i < s.length(); i++) {
            if(letter[(int)(s.charAt(i)-'a')] < 0) letter[(int)(s.charAt(i)-'a')] = 1;
            else if(letter[(int)(s.charAt(i)-'a')]==0) letter[(int)(s.charAt(i)-'a')] = i-Integer.MAX_VALUE;
        }
        int minIndex = 0;
        for (int i = 0; i < 26; i++) {
            if(letter[i] < letter[minIndex]) {
                minIndex = i;
            }
        }
        if(letter[minIndex]>=0) return ' ';
        return (char)(((int)'a'+minIndex)) ;
    }
}